
from openai import OpenAI

client = OpenAI(api_key="sk-8aeced12e2ff4ae9aa52ee208ea19b47", base_url="https://api.deepseek.com")

question_item = "我"

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "你是一个同义词生成助手，请为给定的词生成 3 个同义词。格式为：词1|词2|词3"},
        {"role": "user", "content": f"请为以下词生成 3 个同义词：'{question_item}'"}
    ],
    stream=False
)
# 提取生成的同义词
generated_text = response.choices[0].message.content
print(generated_text)
synonyms = [s.strip() for s in generated_text.split("|") if s.strip()]
print(synonyms)
